package com.szbber.medical.board.ui.activity

import android.view.View
import androidx.fragment.app.Fragment
import androidx.lifecycle.ViewModelProvider
import com.szbber.commen.base.BaseFragmentPageAdapter
import com.szbber.commen.base.BaseVMActivity
import com.szbber.medical.board.R
import com.szbber.medical.board.databinding.BoardActivityPatientDetalisBinding
import com.szbber.medical.board.databinding.BoardFragmentPatientlistBinding
import com.szbber.medical.board.ui.fragment.dialog.MessageInfoFragment
import com.szbber.medical.board.ui.fragment.dialog.OrderInfoFragment
import com.szbber.medical.board.ui.fragment.dialog.PatientDetailsFragment
import com.szbber.medical.board.viewModel.PatientDetalisViewModel
import kotlinx.android.synthetic.main.board_activity_patient_detalis.*

class PatientDetalisActivity : BaseVMActivity<BoardActivityPatientDetalisBinding, PatientDetalisViewModel>() {


    private var myAdapter: BaseFragmentPageAdapter? = null
    private val mTitleList = ArrayList<String>()
    private val mFragments: ArrayList<Fragment> = ArrayList()
    private var cureNo:String? = null

    override fun bindLayout(): Int =R.layout.board_activity_patient_detalis
    override fun initView() {
        mBinding.patientDetailsVm = mViewModel
        cureNo = intent.getStringExtra("data")

        mTitleList.add("患者信息")
        mTitleList.add("医嘱信息")
        mTitleList.add("消息推送")

        mFragments.add(PatientDetailsFragment.getInstance(cureNo))
        mFragments.add(OrderInfoFragment.getInstance(cureNo))
        mFragments.add(MessageInfoFragment.getInstance(cureNo))

        myAdapter = BaseFragmentPageAdapter(supportFragmentManager, mFragments, mTitleList)
        mViewPager.adapter = myAdapter
        mViewPager.offscreenPageLimit=3
        mViewPager.currentItem = 0
        mSlidingTabLayout.setViewPager(mViewPager)

         llDelete.setOnClickListener {
            finish()
        }

    }

    override fun initVM(): PatientDetalisViewModel =
        ViewModelProvider(this,
            ViewModelProvider.NewInstanceFactory()).get(PatientDetalisViewModel::class.java)


}